package utils;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

public class CommonUtils {

    public static InputStream readResourceFile(String fileName) {
        return CommonUtils.class.getClassLoader().getResourceAsStream(fileName);
    }

    public static Properties readPropertiesFile(String fileName) throws IOException {
        Properties properties = new Properties();
        InputStream in = CommonUtils.readResourceFile(fileName);
        properties.load(in);
        return properties;
    }

    public static String getCurrentTime(String pattern) {
        return new SimpleDateFormat(pattern).format(new Date());
    }

    /**
     * 获取六位随机数
     */
    public static int getRandomSixFigure() {
        return (int)((Math.random()*9+1)*100000);
    }
}
